package com.smartwebx.ha.web.admin.module.screen.report;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.util.CellRangeAddress;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.dataresolver.Param;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
/**
 * 
 * 创建人：Dream~天涯 
 * 创建时间：2015-6-2 下午3:06:45
 * 邮箱：154494796@qq.com
 * 备注：
 */
public class ExportExcel {
	@Autowired
	private HttpServletRequest request;
	@Autowired
	private HttpServletResponse response;
	public static void main(String[] args) {
		ExportExcel p = new ExportExcel();
		String sTitle =  "[{\"field\":\"col1\",\"header\":\"站码\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col2\",\"header\":\"站名\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col3\",\"header\":\"最大1天雨量\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col4\",\"header\":\"最大1天日期\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col5\",\"header\":\"最大3天雨量\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col6\",\"header\":\"最大3天日期\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col7\",\"header\":\"最大7天雨量\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col8\",\"header\":\"最大7天日期\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col9\",\"header\":\"最大15天雨量\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col10\",\"header\":\"最大15天日期\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col11\",\"header\":\"最大30天雨量\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col12\",\"header\":\"最大30天日期\",\"align\":\"center\",\"headerAlign\":\"center\"}]";
		String sValue = "[{\"col1\":\"32000000\",\"col2\":\"全省\",\"col3\":\"25\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"25\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"25\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"25\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"25\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000100\",\"col2\":\"南京\",\"col3\":\"15\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"15\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"15\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"15\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"15\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32001100\",\"col2\":\"镇江\",\"col3\":\"16\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"16\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"16\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"16\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"16\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000400\",\"col2\":\"常州\",\"col3\":\"17\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"17\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"17\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"17\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"17\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000200\",\"col2\":\"无锡\",\"col3\":\"18\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"18\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"18\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"18\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"18\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000500\",\"col2\":\"苏州\",\"col3\":\"19\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"19\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"19\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"19\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"19\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000600\",\"col2\":\"南通\",\"col3\":\"20\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"20\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"20\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"20\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"20\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32001000\",\"col2\":\"扬州\",\"col3\":\"21\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"21\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"21\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"21\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"21\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32001200\",\"col2\":\"泰州\",\"col3\":\"22\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"22\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"22\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"22\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"22\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000900\",\"col2\":\"盐城\",\"col3\":\"23\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"23\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"23\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"23\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"23\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000800\",\"col2\":\"淮安\",\"col3\":\"24\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"24\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"24\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"24\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"24\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32001300\",\"col2\":\"宿迁\",\"col3\":\"25\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"25\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"25\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"25\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"25\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000300\",\"col2\":\"徐州\",\"col3\":\"26\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"26\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"26\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"26\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"26\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000700\",\"col2\":\"连云港\",\"col3\":\"27\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"27\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"27\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"27\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"27\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002100\",\"col2\":\"淮北\",\"col3\":\"28\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"28\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"28\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"28\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"28\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002200\",\"col2\":\"江淮\",\"col3\":\"29\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"29\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"29\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"29\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"29\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002300\",\"col2\":\"苏南\",\"col3\":\"30\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"30\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"30\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"30\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"30\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32003100\",\"col2\":\"淮河\",\"col3\":\"31\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"31\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"31\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"31\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"31\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32003200\",\"col2\":\"长江\",\"col3\":\"32\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"32\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"32\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"32\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"32\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32003300\",\"col2\":\"太湖\",\"col3\":\"33\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"33\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"33\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"33\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"33\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32003110\",\"col2\":\"沂沭泗\",\"col3\":\"34\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"34\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"34\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"34\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"34\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32003120\",\"col2\":\"淮河下游\",\"col3\":\"35\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"35\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"35\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"35\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"35\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002150\",\"col2\":\"淮北防办\",\"col3\":\"36\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"36\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"36\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"36\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"36\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002250\",\"col2\":\"江淮防办\",\"col3\":\"37\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"37\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"37\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"37\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"37\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002350\",\"col2\":\"沿江苏南\",\"col3\":\"38\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"38\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"38\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"38\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"38\",\"col12\":\"2015-05-04 08:00:00.0\"}]";
		String title = "区域最大1、3、7、15、30天雨量报表查询";
		//p.exportExcel(title,sTitle,sValue);
	}
	
	public void execute(@Param("title") String title, @Param("sTitle") String sTitle, @Param("sValue") String sValue) throws IOException{
		//sTitle =  "[{\"field\":\"col1\",\"header\":\"站码\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col2\",\"header\":\"站名\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col3\",\"header\":\"最大1天雨量\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col4\",\"header\":\"最大1天日期\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col5\",\"header\":\"最大3天雨量\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col6\",\"header\":\"最大3天日期\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col7\",\"header\":\"最大7天雨量\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col8\",\"header\":\"最大7天日期\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col9\",\"header\":\"最大15天雨量\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col10\",\"header\":\"最大15天日期\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col11\",\"header\":\"最大30天雨量\",\"align\":\"center\",\"headerAlign\":\"center\"},{\"field\":\"col12\",\"header\":\"最大30天日期\",\"align\":\"center\",\"headerAlign\":\"center\"}]";
		//sValue = "[{\"col1\":\"32000000\",\"col2\":\"全省\",\"col3\":\"25\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"25\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"25\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"25\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"25\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000100\",\"col2\":\"南京\",\"col3\":\"15\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"15\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"15\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"15\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"15\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32001100\",\"col2\":\"镇江\",\"col3\":\"16\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"16\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"16\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"16\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"16\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000400\",\"col2\":\"常州\",\"col3\":\"17\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"17\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"17\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"17\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"17\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000200\",\"col2\":\"无锡\",\"col3\":\"18\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"18\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"18\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"18\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"18\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000500\",\"col2\":\"苏州\",\"col3\":\"19\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"19\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"19\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"19\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"19\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000600\",\"col2\":\"南通\",\"col3\":\"20\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"20\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"20\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"20\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"20\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32001000\",\"col2\":\"扬州\",\"col3\":\"21\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"21\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"21\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"21\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"21\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32001200\",\"col2\":\"泰州\",\"col3\":\"22\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"22\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"22\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"22\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"22\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000900\",\"col2\":\"盐城\",\"col3\":\"23\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"23\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"23\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"23\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"23\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000800\",\"col2\":\"淮安\",\"col3\":\"24\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"24\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"24\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"24\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"24\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32001300\",\"col2\":\"宿迁\",\"col3\":\"25\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"25\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"25\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"25\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"25\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000300\",\"col2\":\"徐州\",\"col3\":\"26\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"26\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"26\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"26\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"26\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32000700\",\"col2\":\"连云港\",\"col3\":\"27\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"27\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"27\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"27\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"27\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002100\",\"col2\":\"淮北\",\"col3\":\"28\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"28\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"28\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"28\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"28\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002200\",\"col2\":\"江淮\",\"col3\":\"29\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"29\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"29\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"29\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"29\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002300\",\"col2\":\"苏南\",\"col3\":\"30\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"30\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"30\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"30\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"30\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32003100\",\"col2\":\"淮河\",\"col3\":\"31\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"31\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"31\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"31\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"31\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32003200\",\"col2\":\"长江\",\"col3\":\"32\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"32\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"32\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"32\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"32\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32003300\",\"col2\":\"太湖\",\"col3\":\"33\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"33\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"33\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"33\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"33\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32003110\",\"col2\":\"沂沭泗\",\"col3\":\"34\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"34\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"34\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"34\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"34\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32003120\",\"col2\":\"淮河下游\",\"col3\":\"35\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"35\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"35\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"35\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"35\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002150\",\"col2\":\"淮北防办\",\"col3\":\"36\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"36\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"36\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"36\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"36\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002250\",\"col2\":\"江淮防办\",\"col3\":\"37\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"37\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"37\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"37\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"37\",\"col12\":\"2015-05-04 08:00:00.0\"},{\"col1\":\"32002350\",\"col2\":\"沿江苏南\",\"col3\":\"38\",\"col4\":\"2015-06-01 08:00:00.0\",\"col5\":\"38\",\"col6\":\"2015-05-31 08:00:00.0\",\"col7\":\"38\",\"col8\":\"2015-05-27 08:00:00.0\",\"col9\":\"38\",\"col10\":\"2015-05-19 08:00:00.0\",\"col11\":\"38\",\"col12\":\"2015-05-04 08:00:00.0\"}]";
		//title = "222";
		response.setContentType("application/x-download");
		response.addHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(title, "UTF-8")+".xls");
		List<Map<String, Object>> listTitle = JSON.parseObject(sTitle, new TypeReference<List<Map<String,Object>>>(){});
		List<Map<String, Object>> listValue = JSON.parseObject(sValue, new TypeReference<List<Map<String,Object>>>(){});
		
		// 创建Excel的工作书册 Workbook,对应到一个excel文档
		HSSFWorkbook wb = new HSSFWorkbook();

		// 创建Excel的工作sheet,对应到一个excel文档的tab
		HSSFSheet sheet = wb.createSheet("sheet1");

		// 设置excel每列宽度
		sheet.setColumnWidth(0, 4000);
		sheet.setColumnWidth(1, 3500);

		// 创建字体样式
		HSSFFont font = wb.createFont();
		font.setFontName("Verdana");
		font.setBoldweight((short) 100);
		font.setFontHeight((short) 300);
		font.setColor(HSSFColor.BLUE.index);

		// 创建单元格样式
		HSSFCellStyle style = wb.createCellStyle();
		style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
		style.setFillForegroundColor(HSSFColor.LIGHT_TURQUOISE.index);
		style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

		// 设置边框
		style.setBottomBorderColor(HSSFColor.RED.index);
		style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
		style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
		style.setBorderRight(HSSFCellStyle.BORDER_THIN);
		style.setBorderTop(HSSFCellStyle.BORDER_THIN);

		style.setFont(font);// 设置字体

		// 创建Excel的sheet的一行
		HSSFRow row = sheet.createRow(0);
		row.setHeight((short) 500);// 设定行的高度
		// 创建一个Excel的单元格
		HSSFCell cell = row.createCell(0);

		// 合并单元格(startRow，endRow，startColumn，endColumn)
		sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, listTitle.size()-2));

		// 给Excel的单元格设置样式和赋值
		cell.setCellStyle(style);
		cell.setCellValue(title);

		/*// 设置单元格内容格式
		HSSFCellStyle style1 = wb.createCellStyle();
		style1.setDataFormat(HSSFDataFormat.getBuiltinFormat("h:mm:ss"));

		style1.setWrapText(true);// 自动换行
*/		
		row = sheet.createRow(1);
		for(int j=0;j<listTitle.size()-1;j++){
			cell = row.createCell(j);
			cell.setCellValue(listTitle.get(j+1).get("header").toString());
		}
		
		for (int i = 2;i < listValue.size()+2; i++) {
			row = sheet.createRow(i);
			for(int m=0;m<listValue.get(0).size();m++){
				cell = row.createCell(m);
				cell.setCellValue(listValue.get(i-2).get("col"+(m+1)).toString());
			}
			
		}

		//FileOutputStream os;
		try {
			
			OutputStream out = response.getOutputStream();
			wb.write(out);
			out.close();
			
			/*os = new FileOutputStream("D:\\"+title+".xls");
			wb.write(os);
			os.close();*/
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
	
	public static String getRealPath(HttpServletRequest request,String url){
 		String path = request.getSession().getServletContext()
				.getRealPath(url);
		return path;
	}
}



